package ebcs.database.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ebcs.database.bean.BsFundsApply;
import ebcs.database.bean.ProjectCostInfo;
import ebcs.database.mybatis.dao.BsFundsApplyMapper;
import ebcs.database.service.BsFundsApplyServiceImp;
import jplat.tools.string.DateUtil;

@Service
public class BsFundsApplyServiceImpl implements BsFundsApplyServiceImp{

	@Autowired
	private BsFundsApplyMapper bsFundsApplyDao;
	
	@Override
	public void saveApplyFunds(String need_id) {
		// TODO Auto-generated method stub
		String apply_date = DateUtil.formatDateToStr(new Date(), "yyyyMMdd");
		BsFundsApply bsFundsApply = new BsFundsApply();
		bsFundsApply.setNeed_id(need_id);
		bsFundsApply.setApply_date(apply_date);
		bsFundsApply.setCw_state("00");
		bsFundsApply.setRl_state("00");
		bsFundsApply.setState("00");
		String rouid = UUID.randomUUID().toString().replaceAll("-", "");
		bsFundsApply.setRouid(rouid);
		bsFundsApplyDao.saveApplyFunds(bsFundsApply);
	}
	
	@Override
	public List<BsFundsApply> searchChaKan(BsFundsApply example) {
		// TODO Auto-generated method stub
		return bsFundsApplyDao.selectChaKan(example);
	}

	@Override
	public int tongGuoNeedById(BsFundsApply example) {
		// TODO Auto-generated method stub
		return bsFundsApplyDao.updateNeedById(example);
	}
	@Override
	public int boHuiNeedById(BsFundsApply example) {
		// TODO Auto-generated method stub
		return bsFundsApplyDao.updateNeedById(example);
	}

	@Override
	public List<BsFundsApply> selectApplyFunds(String need_id) {
		// TODO Auto-generated method stub
		BsFundsApply BsFundsApply =new BsFundsApply();
		BsFundsApply.setNeed_id(need_id);
		return bsFundsApplyDao.selectApplyFunds(BsFundsApply);
	}

	@Override
	public int updateByNeedId(String need_id) {
		// TODO Auto-generated method stub
		BsFundsApply BsFundsApply =new BsFundsApply();
		String apply_date = DateUtil.formatDateToStr(new Date(), "yyyyMMdd");
		BsFundsApply.setNeed_id(need_id);
		BsFundsApply.setApply_date(apply_date);
		BsFundsApply.setState("00");
		BsFundsApply.setRl_state("00");
		BsFundsApply.setCw_state("00");
		return bsFundsApplyDao.updateByNeedId(BsFundsApply);
	}
	
	@Override
	public BsFundsApply selectApplyFundsByRouid(String rouid) {
		// TODO Auto-generated method stub
		BsFundsApply BsFundsApply =new BsFundsApply();
		BsFundsApply.setRouid(rouid);
		return bsFundsApplyDao.selectApplyFundsByRouid(BsFundsApply);
	}
	
}
